//
//  CollectionReusableViewTitle1.m
//  jingdongfang
//
//  Created by RKL on 2018/5/10.
//  Copyright © 2018年 BOE-SBG-CTO. All rights reserved.
//

#import "CollectionReusableViewTitle1.h"

@implementation CollectionReusableViewTitle1
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    UIButton * titleBtn = ({
        UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(0, 0, KSCREENWIDTH/2, 50);
        [button addTarget:self action:@selector(titleBtnClick) forControlEvents:UIControlEventTouchUpInside];
        button;
    });
    [self addSubview:titleBtn];
    
    UIImageView * iconImage = [UIImageView new];
    iconImage.image = [UIImage imageNamed:@"picture_all_ts"];
    iconImage.frame = CGRectMake(10, (50 - 15)/2, 15, 15);
    [titleBtn addSubview:iconImage];
    
    UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(iconImage.frame) + 8, 0, 80, 50)];
    titleLabel.centerY = iconImage.centerY;
    titleLabel.text = @"全部推送";
    titleLabel.textColor = [UIColor c4Color];
    titleLabel.font = [UIFont systemFontOfSize:19];
    [titleBtn addSubview:titleLabel];
    
    UILabel * totolNum = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(titleLabel.frame) + 8, 0, 150, 50)];
    totolNum.centerY = iconImage.centerY;
    totolNum.text = @"(15)";
    totolNum.textColor = [UIColor c5Color];
    totolNum.font = [UIFont systemFontOfSize:19];
    _totolNum = totolNum;
    [self addSubview:totolNum];
    
    
    UIButton * selectBtn = ({
        UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(KSCREENWIDTH/2, 0, KSCREENWIDTH/2, 50);
        [button addTarget:self action:@selector(selectBtnClick) forControlEvents:UIControlEventTouchUpInside];
        button;
    });
    [self addSubview:selectBtn];
    
    UIImageView * coverRightArrowImageView = ({
        UIImageView * imageView = [[UIImageView alloc] init];
        imageView.image = [UIImage imageNamed:@"picture_right_arrow"];
        imageView.frame = CGRectMake(KSCREENWIDTH/2-23, 0, 8, 13);
        imageView.centerY = iconImage.centerY;
        imageView.userInteractionEnabled = YES;
        imageView;
    });
    [selectBtn addSubview:coverRightArrowImageView];
    
    
    UILabel * selectTitle = [[UILabel alloc] initWithFrame:CGRectMake(KSCREENWIDTH/2 - 50 -28, 0, 50, 50)];
    selectTitle.text = @"多选";
    selectTitle.textAlignment = NSTextAlignmentCenter;
    selectTitle.centerY = iconImage.centerY;
    selectTitle.textColor = [UIColor c4Color];
    selectTitle.font = [UIFont systemFontOfSize:16];
    [selectBtn addSubview:selectTitle];
    
}

- (void)titleBtnClick
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(clickAllPull)])
    {
        [self.delegate clickAllPull];
    }
}
- (void)selectBtnClick
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(clickSelectMore)])
    {
        [self.delegate clickSelectMore];
    }
}

@end
